//
//  HeaderNavBar.m
//  Qbutton
//
//  Created by CHENGXIANG QIU on 2018/6/14.
//  Copyright © 2018年 CHENGXIANG QIU. All rights reserved.
//

#import "HeaderNavBar.h"

@implementation HeaderNavBar
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:rect];
    if(scrollView){
        scrollView.backgroundColor = [UIColor yellowColor];
        scrollView.contentSize = CGSizeMake([UIScreen mainScreen].bounds.size.width-20, 350);
        scrollView.directionalLockEnabled = YES;
        scrollView.showsVerticalScrollIndicator = YES;
        scrollView.pagingEnabled = NO;
        scrollView.scrollEnabled = YES;
        scrollView.indicatorStyle = UIScrollViewIndicatorStyleBlack;
        scrollView.showsHorizontalScrollIndicator = NO;
        scrollView.delegate = self;
        scrollView.bounces = YES;
        scrollView.alwaysBounceVertical = NO;
        scrollView.alwaysBounceHorizontal = NO;
    }
}
//只要滚动了就会触发

- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
    //    NSLog(@" scrollViewDidScroll");
    NSLog(@"X = %f,Y = %f",scrollView.contentOffset.x,scrollView.contentOffset.y);
}

//开始拖拽视图
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{
    NSLog(@"scrollViewWillBeginDragging");
}

//完成拖拽

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{
    NSLog(@"scrollViewDidEndDragging");
}

//将开始降速时
- (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView{
    NSLog(@"scrollViewWillBeginDecelerating");
}

//减速停止了时执行，手触摸时执行执行

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView;
{
    
    NSLog(@"scrollViewDidEndDecelerating");
    
}

//滚动动画停止时执行,代码改变时出发,也就是setContentOffset改变时

- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView;
{
    
    NSLog(@"scrollViewDidEndScrollingAnimation");
    
}

//设置放大缩小的视图，要是uiscrollview的subview

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView;
{
    
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 10, 10)];
    
    NSLog(@"viewForZoomingInScrollView");
    
    return view;
    
}

//完成放大缩小时调用

- (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(double)scale{
    
    view.frame=CGRectMake(50,0,100,400);
    
    NSLog(@"scrollViewDidEndZooming");
    
}

//如果你不是完全滚动到滚轴视图的顶部，你可以轻点状态栏，那个可视的滚轴视图会一直滚动到顶部，那是默认行为，你可以通过该方法返回NO来关闭它

- (BOOL)scrollViewShouldScrollToTop:(UIScrollView *)scrollView;
{
    
    NSLog(@"scrollViewShouldScrollToTop");
    
    return YES;
    
}

- (void)scrollViewDidScrollToTop:(UIScrollView *)scrollView;
{
    
    NSLog(@"scrollViewDidScrollToTop");
    
}
@end
